<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/jsp/common/page_init.jsp"%>
<%
	JSONObject targetSysList = (JSONObject) request.getAttribute("targetSysList");
%>
<head>
<meta charset="utf-8">
<title>uploadify demo</title>
<link rel="stylesheet" href="<%=contextPath%>/js/common/plug-in/uploadify/uploadify.css" type="text/css"></link>
<script type="text/javascript" src="<%=contextPath%>/js/common/plug-in/uploadify/jquery.uploadify-3.1.min.js"></script>

<script type="text/javascript">
$(function() {
    $("#file_upload").uploadify({
    	'height'        : 27, 
    	'width'         : 80,  
    	'buttonText'    : '浏 览',
        'swf'           : '<%=contextPath%>/js/common/plug-in/uploadify/uploadify.swf',
        'uploader'      : '<%=contextPath%>/demo/uploadify',
        'auto'          : false,
        'removeCompleted':false,
        'fileTypeExts'  : '*.pkg',
        'formData'      : {'targetId':''},
        'onUploadStart' : function(file) {
        	 
            var targetId=$('#targetId').val();    
        	$("#file_upload").uploadify("settings", "formData", {'targetId':targetId});
        	//$("#file_upload").uploadify("settings", "qq", );
        },
        'onSelect' : function(file){
        	//console.log(JSON.stringify(file));
        	Ajax({
    			url: contextPath+"/demo/checkModule",
    			isMask : true,
    			data: {
    				"module":file.name,
    				"targetId":$('#targetId').val()
    			},
    			success: function (data) {
    				if (data.code <0) {
			        	$("#"+file.id).find("span.data").addClass("red");
			        	$("#"+file.id).find("span.data").text("  "+data.note);
			        	if(data.code==-2){
			        		setTimeout(function(){
				        		$('#file_upload').uploadify('cancel', file.id);
			        		},3000); 
			        	}
    				}else{
			        	$("#"+file.id).find("span.data").addClass("green");
			        	$("#"+file.id).find("span.data").text("  "+data.note);
    				}
    			}
    		}); 
        }
    });
});

</script>
</head>
<body>
		上游系统：<select id="targetId" name="targetId" class="width-180">
					  				<%if(targetSysList.getIntValue("code")>-1&&targetSysList.getIntValue("count")>0){
					  					JSONArray targetSys_records = targetSysList.getJSONArray("records");
					  					for(int i = 0;i<targetSys_records.size();i++){
					  						JSONObject targetSys_row = targetSys_records.getJSONObject(i);
					  						
					  						//禁用状态的目标系统不允许添加
					  						if(targetSys_row.getIntValue("status")==EsbConstant.EFFECT_STATUS_STOP){
					  							continue;
					  						}
					  				%>	
					  					<option value="<%=targetSys_row.getString("targetId")%>">
					  							<%=targetSys_row.getString("targetName")%>
					  					</option>
					  					
					  				<%}}else{%>
					  					<option value="">-----请选择-----</option>
					  				<%} %>
							</select>
		<input type="file" name="uploadify" id="file_upload"/>
		<hr>
		<a href="javascript:$('#file_upload').uploadify('upload','*')">开始上传</a>&nbsp;   
        <a href="javascript:$('#file_upload').uploadify('cancel', '*')">取消所有上传</a> 

</body>
</html>